// Tetris board class.
// The Tetris board is a 2D array of cells. Each cell contains an integer.
// A cell containing zero is interpreted to be empty; a cell containing a
// non-zero value is non-empty. The meaning of a non-zero value is not specified
// by this class.
public class TetrisBoard {
private int nRows, nCols;
private int[][] cells;
// Construct a Tetris Board of the given size.
public TetrisBoard(int nRows, int nCols) {
this.nRows = nRows;
this.nCols = nCols;
this.cells = new int[nRows][nCols];
}
// How big is the board?
public int getNumRows() { return nRows; }
public int getNumCols() { return nCols; }
// What is in this cell?
public int get(int row, int col) {
return cells[row][col];
}
// Set this cell.
public void set(int row, int col, int v) {
cells[row][col] = v;
}
// Can the given piece be placed at the given location on this board?
public boolean canPlacePiece(TetrisPiece piece, int row, int col) {
return true;
}
// Place the given piece at the given location on this board. Fill board
// locations occupied by the piece with the value v.
// Precondition: canPlacePiece(piece,row,col) is true.
public void placePiece(TetrisPiece piece, int row, int col, int v) {
}
// If there are any filled rows in the board: remove them, shift cells down,
// and return the number of filled rows.
public int clearFilledRows(int minRow, int maxRow, int minCol, int maxCol) {
return 0;
}
}

